import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart';

class HelpCenterPage extends StatefulWidget {
  const HelpCenterPage({super.key});

  @override
  State<HelpCenterPage> createState() => _HelpCenterPageState();
}

class _HelpCenterPageState extends State<HelpCenterPage> {
  Widget _buildQuestionGroup(String title, List<String> questions) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Padding(
            padding: const EdgeInsets.all(16),
            child: Text(
              title,
              style: const TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.w500,
              ),
            ),
          ),
          Divider(height: 1, color: Colors.grey[100]),
          ...questions.map((question) => Column(
            children: [
              ListTile(
                title: Text(
                  question,
                  style: const TextStyle(fontSize: 15),
                ),
                trailing: Icon(
                  Icons.chevron_right,
                  size: 20,
                  color: Colors.grey[400],
                ),
                onTap: () {
                  // TODO: 查看问题详情
                },
              ),
              Divider(height: 1, color: Colors.grey[100]),
            ],
          )).toList(),
        ],
      ),
    );
  }

  Future<void> _showAppInfo() async {
    final packageInfo = await PackageInfo.fromPlatform();
    if (!mounted) return;
    
    showDialog(
      context: context,
      builder: (context) => AlertDialog(
        title: const Text('关于应用'),
        content: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text('版本: ${packageInfo.version}'),
            Text('构建号: ${packageInfo.buildNumber}'),
            const SizedBox(height: 8),
            const Text('客服电话: 400-888-8888'),
          ],
        ),
        actions: [
          TextButton(
            onPressed: () => Navigator.pop(context),
            child: const Text('确定'),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFFF5F5F5),
      appBar: AppBar(
        title: const Text(
          '帮助中心',
          style: TextStyle(
            fontSize: 18,
            fontWeight: FontWeight.w500,
          ),
        ),
        centerTitle: true,
        backgroundColor: Colors.white,
        elevation: 0,
      ),
      body: ListView(
        padding: const EdgeInsets.all(12),
        children: [
          _buildQuestionGroup(
            '常见问题',
            [
              '如何注册成为搬家师傅？',
              '如何接单？',
              '如何联系客户？',
              '如何申请提现？',
            ],
          ),
          const SizedBox(height: 12),
          _buildQuestionGroup(
            '账号问题',
            [
              '如何修改手机号？',
              '如何注销账号？',
              '账号被冻结怎么办？',
            ],
          ),
          const SizedBox(height: 12),
          _buildQuestionGroup(
            '订单问题',
            [
              '订单取消规则',
              '订单完成后未收到款项',
              '如何处理订单纠纷？',
            ],
          ),
          const SizedBox(height: 24),
          Container(
            padding: const EdgeInsets.all(16),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(8),
            ),
            child: Row(
              children: [
                Icon(
                  Icons.support_agent_outlined,
                  color: Colors.grey[600],
                ),
                const SizedBox(width: 12),
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      const Text(
                        '在线客服',
                        style: TextStyle(
                          fontSize: 15,
                          fontWeight: FontWeight.w500,
                        ),
                      ),
                      const SizedBox(height: 2),
                      Text(
                        '工作时间：9:00-18:00',
                        style: TextStyle(
                          fontSize: 13,
                          color: Colors.grey[600],
                        ),
                      ),
                    ],
                  ),
                ),
                TextButton(
                  onPressed: () {
                    // TODO: 联系客服
                  },
                  style: TextButton.styleFrom(
                    foregroundColor: const Color(0xFFFF5722),
                    padding: const EdgeInsets.symmetric(
                      horizontal: 16,
                      vertical: 8,
                    ),
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(6),
                      side: const BorderSide(
                        color: Color(0xFFFF5722),
                      ),
                    ),
                  ),
                  child: const Text('联系客服'),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
} 